package br.com.linkideias.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.linkideias.model.command.InterfaceCommand;
import br.com.linkideias.model.helper.LinkideiasHelper;

//import br.com.siscom.model.command.InterfaceCommand;
//import br.com.siscom.model.helper.SiscomHelper;

/**
 * Servlet implementation class for Servlet: SiscomController
 *
 */
 public class LinkideiasController extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
   static final long serialVersionUID = 1L;
   
    /* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public LinkideiasController() {
		super();
	}   	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	private void processarRequisicao(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("Estou no Controller");
		LinkideiasHelper linkideiasHelper = new LinkideiasHelper(request);
		InterfaceCommand command = linkideiasHelper.getCommand();
		String pagina = command.execute(request, response);
		request.getRequestDispatcher(pagina).forward(request, response);
	}
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.processarRequisicao(request, response);
	}  	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.processarRequisicao(request, response);
	}   	  	    
}